From 70655cc7fda8f62b4c2b5903faab28b1ad08355c Mon Sep 17 00:00:00 2001 From: "robertlipe@gmail.com" Date: Sun, 5 Jan 2014 22:44:22 +0000 Subject: [PATCH] Cleanups saved for a rainy day? Even without being called out via valgrind, these are "obviously" leaks and a cleanup upportunity. egrep -- '->(rte_name|rte_desc|rte_url|icon|icon_descr|rte_name|rte_desc|notes|shortname|description) = xstrdup' *.cca We've eliminated 58% of the calls to xstrdup that we had in 1.4.4.. git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@4712 f51c46e8-681c-474f-0cfe-069cfd0219fb --- gpsbabel/an1.cc | 2 +- gpsbabel/brauniger_iq.cc | 4 ++-- gpsbabel/cst.cc | 8 ------- gpsbabel/delbin.cc | 19 ++++++----------- gpsbabel/dg-100.cc | 4 ++-- gpsbabel/garmin.cc | 29 +++++++++++-------------- gpsbabel/glogbook.cc | 18 ---------------- gpsbabel/ignrando.cc | 6 ------ gpsbabel/lmx.cc | 24 --------------------- gpsbabel/mapsource.cc | 46 ++-------------------------------------- gpsbabel/mmo.cc | 18 +++------------- gpsbabel/naviguide.cc | 5 ----- gpsbabel/navilink.cc | 4 ---- gpsbabel/overlay.cc | 13 ++---------- gpsbabel/ozi.cc | 39 +--------------------------------- gpsbabel/radius.cc | 2 +- gpsbabel/shape.cc | 2 +- gpsbabel/stmwpp.cc | 4 ---- gpsbabel/transform.cc | 13 +----------- 19 files changed, 35 insertions(+), 225 deletions(-) diff --git a/gpsbabel/an1.cc b/gpsbabel/an1.cc index d8d5cd136..5943e31e8 100644 --- a/gpsbabel/an1.cc +++ b/gpsbabel/an1.cc @@ -729,7 +729,7 @@ static void Read_AN1_Waypoints(gbfile* f) #endif if (rec->image_name) { - wpt_tmp->icon_descr = xstrdup(rec->image_name); + wpt_tmp->icon_descr = rec->image_name; } else if (FindIconByGuid(&rec->guid, &icon)) { wpt_tmp->icon_descr = icon; } diff --git a/gpsbabel/brauniger_iq.cc b/gpsbabel/brauniger_iq.cc index c0e725d9a..a32f44a52 100644 --- a/gpsbabel/brauniger_iq.cc +++ b/gpsbabel/brauniger_iq.cc @@ -191,8 +191,8 @@ static int process_data(const unsigned char* data) } if (remaining) { track = route_head_alloc(); - track->rte_name = xstrdup(PRESTRKNAME); - track->rte_desc = xstrdup("Brauniger-IQ Barograph"); + track->rte_name = PRESTRKNAME; + track->rte_desc = "Brauniger-IQ Barograph"; track_add_head(track); } else { warning(MYNAME ": No barograph recorded for this flight\n"); diff --git a/gpsbabel/cst.cc b/gpsbabel/cst.cc index f7d3f95e6..894eaf44f 100644 --- a/gpsbabel/cst.cc +++ b/gpsbabel/cst.cc @@ -236,11 +236,7 @@ cst_data_read(void) line++; cin = lrtrim(buff); if (*cin != '\0') { -#if NEW_STRINGS wpt->notes = QString::fromLatin1(cin); -#else - wpt->notes = xstrdup(cin); -#endif } } else if (strcmp(cin + 2, "end") == 0) { data = 1; @@ -286,11 +282,7 @@ cst_data_read(void) track = route_head_alloc(); track_add_head(track); } else if (strncmp(name, "NAME:", 5) == 0) { -#if NEW_STRINGS wpt->shortname = QString::fromLatin1(((char*)&name) + 5); -#else - wpt->shortname = xstrdup(((char*)&name) + 5); -#endif } pow = strrchr(cin, '^'); diff --git a/gpsbabel/delbin.cc b/gpsbabel/delbin.cc index f90f5744f..08c47d1e5 100644 --- a/gpsbabel/delbin.cc +++ b/gpsbabel/delbin.cc @@ -1011,7 +1011,7 @@ decode_waypoint(const void* data) // wp->icon_descr = wp->icon_descr; // } if (p->name_size && p->name[0]) { - wp->description = xstrdup(p->name); + wp->description = p->name; } s = p->name + p->name_size; if (le_readu16(s) && s[2]) { @@ -1401,13 +1401,8 @@ write_waypoint(const waypoint* wp) char* pp; if (waypt_empty_gc_data(wp)) { -#if NEW_STRINGS notes = xstrdup(wp->notes); if (notes == NULL && wp->description.isEmpty() && wp->shortname != wp->description) { -#else - notes = wp->notes; - if (notes == NULL && wp->description && strcmp(wp->shortname, wp->description)) { -#endif notes = xstrdup(wp->description); } if (notes) { @@ -1617,7 +1612,7 @@ read_track(route_head* track) // process track messages p = (const msg_track_header_t*) msg_array[0].data; if (le_readu16(p->comment_size)) { - track->rte_desc = xstrdup(p->comment); + track->rte_desc = p->comment; } track->line_color.bbggrr = track_color(p->color[0]); n_point = le_readu32(p->total_points); @@ -1706,7 +1701,7 @@ read_tracks(void) const msg_track_header_t* p = (msg_track_header_t*) msg_array[i].data; if (le_readu32(p->total_points)) { track_array[i] = route_head_alloc(); - track_array[i]->rte_name = xstrdup(p->name); + track_array[i]->rte_name = p->name; } } else { fatal(MYNAME ": unexpected message %x while reading track headers\n", id); @@ -1873,7 +1868,7 @@ decode_route_shape(const void* data, unsigned* wp_array_i) wp->latitude = delbin_rad2deg(le_read32(p->point[i].latitude)); wp->longitude = delbin_rad2deg(le_read32(p->point[i].longitude)); sprintf(buf, "SHP%03u", j); - wp->shortname = xstrdup(buf); + wp->shortname = buf; } *wp_array_i = j; } @@ -1886,7 +1881,7 @@ decode_route_point(const void* data) gbfile* fd = gbfopen(NULL, "w", MYNAME); waypoint* wp = waypt_new(); if (p->name[0]) { - wp->shortname = xstrdup(p->name); + wp->shortname = p->name; } // give these a higher priority than the shape points wp->route_priority = 1; @@ -2094,7 +2089,7 @@ read_routes(void) unsigned id = message_get_id(&msg_array[i]); if (id == MSG_ROUTE_HEADER_OUT) { route_array[i] = route_head_alloc(); - route_array[i]->rte_name = xstrdup(((msg_route_header_t*)msg_array[i].data)->name); + route_array[i]->rte_name = ((msg_route_header_t*)msg_array[i].data)->name; } else { fatal(MYNAME ": unexpected message %x while reading route headers\n", id); } @@ -2292,7 +2287,7 @@ decode_navmsg(const void* data) wp->course /= 100; wp->wpt_flags.course = 1; decode_sat_fix(wp, p->fix_status); - wp->shortname = xstrdup("Position"); + wp->shortname = "Position"; return wp; } diff --git a/gpsbabel/dg-100.cc b/gpsbabel/dg-100.cc index d37a2ea74..b8ad6d5d4 100644 --- a/gpsbabel/dg-100.cc +++ b/gpsbabel/dg-100.cc @@ -261,8 +261,8 @@ process_gpsfile(uint8_t data[], route_head** track) strftime(buf, 4096, "DG-100 tracklog (%Y/%m/%d %H:%M:%S)", gmtime(&creation_time)); *track = route_head_alloc(); - (*track)->rte_name = xstrdup(buf); - (*track)->rte_desc = xstrdup("DG-100 GPS tracklog data"); + (*track)->rte_name = buf; + (*track)->rte_desc = "DG-100 GPS tracklog data"; track_add_head(*track); } diff --git a/gpsbabel/garmin.cc b/gpsbabel/garmin.cc index 111e4cd20..b6f9c4dbc 100644 --- a/gpsbabel/garmin.cc +++ b/gpsbabel/garmin.cc @@ -341,7 +341,7 @@ waypt_read(void) waypoint* wpt = waypt_new(); wpt->latitude = gps_save_lat; wpt->longitude = gps_save_lon; - wpt->shortname = xstrdup("Position"); + wpt->shortname = "Position"; if (gps_save_time) { wpt->SetCreationTime(gps_save_time); } @@ -356,15 +356,10 @@ waypt_read(void) for (i = 0; i < n; i++) { waypoint* wpt_tmp = waypt_new(); - wpt_tmp->shortname = xstrdup(way[i]->ident); - wpt_tmp->description = xstrdup(way[i]->cmnt); -#if NEW_STRINGS + wpt_tmp->shortname = way[i]->ident; + wpt_tmp->description = QString(way[i]->cmnt).simplified(); wpt_tmp->shortname = wpt_tmp->shortname.simplified(); wpt_tmp->description = wpt_tmp->description.simplified(); -#else - rtrim(wpt_tmp->shortname); - rtrim(wpt_tmp->description); -#endif wpt_tmp->longitude = way[i]->lon; wpt_tmp->latitude = way[i]->lat; if (gps_waypt_type == 103) { @@ -481,7 +476,7 @@ track_read(void) if (trk_head == NULL || array[i]->ishdr) { trk_head = route_head_alloc(); trk_head->rte_num = trk_num; - trk_head->rte_name = xstrdup(trk_name); + trk_head->rte_name = trk_name; trk_num++; track_add_head(trk_head); } @@ -503,7 +498,7 @@ track_read(void) wpt->altitude = array[i]->alt; wpt->heartrate = array[i]->heartrate; wpt->cadence = array[i]->cadence; - wpt->shortname = xstrdup(array[i]->trk_ident); + wpt->shortname = array[i]->trk_ident; wpt->SetCreationTime(array[i]->Time); wpt->wpt_flags.is_split = checkWayPointIsAtSplit(wpt, laps, nlaps); @@ -562,7 +557,7 @@ route_read(void) rte_head = route_head_alloc(); route_add_head(rte_head); if (csrc) { - rte_head->rte_name = xstrdup(csrc); + rte_head->rte_name = csrc; } } else { if (array[i]->islink) { @@ -620,7 +615,7 @@ lap_read_as_track(void) /*For D906, we would like to use the track_index in the last packet instead...*/ trk_head->rte_num = ++trk_num; strftime(tbuf, 32, "%Y-%m-%dT%H:%M:%SZ", stmp); - trk_head->rte_name = xstrdup(tbuf); + trk_head->rte_name = tbuf; track_add_head(trk_head); wpt = waypt_new(); @@ -634,11 +629,11 @@ lap_read_as_track(void) wpt->microseconds = 0; sprintf(tbuf, "#%d-0", index); - wpt->shortname = xstrdup(tbuf); + wpt->shortname = tbuf; sprintf(tbuf, "D:%f Cal:%d MS:%f AH:%d MH:%d AC:%d I:%d T:%d", array[i]->total_distance, array[i]->calories, array[i]->max_speed, array[i]->avg_heart_rate, array[i]->max_heart_rate, array[i]->avg_cadence, array[i]->intensity, array[i]->trigger_method); - wpt->description = xstrdup(tbuf); + wpt->description = tbuf; track_add_wpt(trk_head, wpt); } /*Allow even if no correct location, no skip if invalid */ @@ -657,12 +652,12 @@ lap_read_as_track(void) wpt->microseconds = 10000*(array[i]->total_time % 100); /*Add fields with no mapping in the description */ sprintf(tbuf, "#%d", index); - wpt->shortname = xstrdup(tbuf); + wpt->shortname = tbuf; sprintf(tbuf, "D:%f Cal:%d MS:%f AH:%d MH:%d AC:%d I:%d T:%d (%f,%f)", array[i]->total_distance, array[i]->calories, array[i]->max_speed, array[i]->avg_heart_rate, array[i]->max_heart_rate, array[i]->avg_cadence, array[i]->intensity, array[i]->trigger_method, array[i]->begin_lon, array[i]->begin_lat); - wpt->description = xstrdup(tbuf); + wpt->description = tbuf; track_add_wpt(trk_head, wpt); } @@ -761,7 +756,7 @@ pvt_read(posn_status* posn_status) pvt2wpt(pvt, wpt); GPS_Pvt_Del(&pvt); - wpt->shortname = xstrdup("Position"); + wpt->shortname = "Position"; if (gps_errno && posn_status) { posn_status->request_terminate = 1; diff --git a/gpsbabel/glogbook.cc b/gpsbabel/glogbook.cc index e51120fc8..ad985d269 100644 --- a/gpsbabel/glogbook.cc +++ b/gpsbabel/glogbook.cc @@ -144,12 +144,6 @@ void gl_trk_s(xg_string args, const QXmlStreamAttributes* unused) trk_head = route_head_alloc(); track_add_head(trk_head); } -#if 0 -void gl_trk_ident(xg_string args, const QXmlStreamAttributes* unused) -{ - trk_head->rte_name = xstrdup(args); -} -#endif void gl_trk_pnt_s(xg_string args, const QXmlStreamAttributes* unused) { @@ -168,29 +162,17 @@ void gl_trk_utc(xg_string args, const QXmlStreamAttributes* unused) void gl_trk_lat(xg_string args, const QXmlStreamAttributes* unused) { -#if NEW_STRINGS wpt_tmp->latitude = args.toDouble(); -#else - wpt_tmp->latitude = atof(args); -#endif } void gl_trk_long(xg_string args, const QXmlStreamAttributes* unused) { -#if NEW_STRINGS wpt_tmp->longitude = args.toDouble(); -#else - wpt_tmp->longitude = atof(args); -#endif } void gl_trk_alt(xg_string args, const QXmlStreamAttributes* unused) { -#if NEW_STRINGS wpt_tmp->altitude = args.toDouble(); -#else - wpt_tmp->altitude = atof(args); -#endif } diff --git a/gpsbabel/ignrando.cc b/gpsbabel/ignrando.cc index c595cad0c..bb8c43bb6 100644 --- a/gpsbabel/ignrando.cc +++ b/gpsbabel/ignrando.cc @@ -103,13 +103,7 @@ static void ignr_descr(xg_string args, const QXmlStreamAttributes* attrv) { ignr_xml_error((track == NULL)); -#if NEW_STRINGS track->rte_desc = args; -#else - if ((args != NULL) && (strlen(args) > 0)) { - track->rte_desc = xstrdup(args); - } -#endif } static void diff --git a/gpsbabel/lmx.cc b/gpsbabel/lmx.cc index faae951cc..462fd744a 100644 --- a/gpsbabel/lmx.cc +++ b/gpsbabel/lmx.cc @@ -219,11 +219,7 @@ lmx_print(const waypoint* wpt) if (!oname.isEmpty()) { lmx_write_xml(0x48, oname, 3); // name } -#if NEW_STRINGS if (!wpt->description.isEmpty()) { -#else - if (wpt->description) { -#endif lmx_write_xml(0x49, wpt->description, 3); // description } lmx_start_tag(0x4A, 3); // coordinates @@ -354,51 +350,31 @@ lmx_lm_end(xg_string args, const QXmlStreamAttributes* unused) static void lmx_lm_lat(xg_string args, const QXmlStreamAttributes* unused) { -#if NEW_STRINGS wpt_tmp->latitude = args.toDouble(); -#else - wpt_tmp->latitude = atof(args); -#endif } static void lmx_lm_lon(xg_string args, const QXmlStreamAttributes* unused) { -#if NEW_STRINGS wpt_tmp->longitude = args.toDouble(); -#else - wpt_tmp->longitude = atof(args); -#endif } static void lmx_lm_alt(xg_string args, const QXmlStreamAttributes* unused) { -#if NEW_STRINGS wpt_tmp->altitude = args.toDouble(); -#else - wpt_tmp->altitude = atof(args); -#endif } static void lmx_lm_name(xg_string args, const QXmlStreamAttributes* unused) { -#if NEW_STRINGS wpt_tmp->shortname = args; -#else - wpt_tmp->shortname = xstrdup(args); -#endif } static void lmx_lm_desc(xg_string args, const QXmlStreamAttributes* unused) { -#if NEW_STRINGS wpt_tmp->description = args; -#else - wpt_tmp->description = xstrdup(args); -#endif } static void diff --git a/gpsbabel/mapsource.cc b/gpsbabel/mapsource.cc index 4ceb34b09..87ae93627 100644 --- a/gpsbabel/mapsource.cc +++ b/gpsbabel/mapsource.cc @@ -632,21 +632,12 @@ mps_waypoint_w(gbfile* mps_file, int mps_ver, const waypoint* wpt, const int isR mps_depth = wpt->depth; } QString src; -#if NEW_STRINGS if (!wpt->description.isEmpty()) { src = wpt->description; } if (!wpt->notes.isEmpty()) { src = wpt->notes; } -#else - if (wpt->description) { - src = wpt->description; - } - if (wpt->notes) { - src = wpt->notes; - } -#endif QString ident = global_opts.synthesize_shortnames ? mkshort(mkshort_handle, src) : CSTRc(wpt->shortname); @@ -663,11 +654,7 @@ mps_waypoint_w(gbfile* mps_file, int mps_ver, const waypoint* wpt, const int isR icon = mps_converted_icon_number(icon, mps_ver, MAPSOURCE); /* two NULL (0x0) bytes at end of each string */ -#if NEW_STRINGS ascii_description = xstrdup(wpt->description); -#else - ascii_description = wpt->description ? xstrdup(wpt->description) : xstrdup(""); -#endif reclen = ident.length() + strlen(ascii_description) + 2; if ((mps_ver == 4) || (mps_ver == 5)) { /* v4.06 & V5.0*/ @@ -764,11 +751,7 @@ mps_waypoint_w(gbfile* mps_file, int mps_ver, const waypoint* wpt, const int isR gbfwrite(zbuf, 2, 1, mps_file); /* unknown */ if ((mps_ver == 4) || (mps_ver == 5)) { gbfwrite(zbuf, 4, 1, mps_file); /* unknown */ -#if NEW_STRINGS if (!wpt->notes.isEmpty()) { -#else - if (wpt->notes) { -#endif gbfputs(wpt->notes, mps_file); } gbfwrite(zbuf, 1, 1, mps_file); /* string termination */ @@ -1037,7 +1020,7 @@ mps_route_r(gbfile* mps_file, int mps_ver, route_head** rte) fprintf(stderr, "mps_route_r: reached the point we never should\n"); #endif thisWaypoint = waypt_new(); - thisWaypoint->shortname = xstrdup(wptname); + thisWaypoint->shortname = wptname; thisWaypoint->latitude = GPS_Math_Semi_To_Deg(lat); thisWaypoint->longitude = GPS_Math_Semi_To_Deg(lon); thisWaypoint->altitude = mps_altitude; @@ -1121,7 +1104,7 @@ mps_route_r(gbfile* mps_file, int mps_ver, route_head** rte) } else { /* should never reach here, but we do need a fallback position */ thisWaypoint = waypt_new(); - thisWaypoint->shortname = xstrdup(wptname); + thisWaypoint->shortname = wptname; thisWaypoint->latitude = GPS_Math_Semi_To_Deg(lat); thisWaypoint->longitude = GPS_Math_Semi_To_Deg(lon); thisWaypoint->altitude = mps_altitude; @@ -1201,18 +1184,10 @@ mps_routehdr_w(gbfile* mps_file, int mps_ver, const route_head* rte) } QString src; -#if NEW_STRINGS if (!testwpt->description.isEmpty()) { -#else - if (testwpt->description) { -#endif src = testwpt->description; } -#if NEW_STRINGS if (!testwpt->notes.isEmpty()) { -#else - if (testwpt->notes) { -#endif src = testwpt->notes; } QString ident = global_opts.synthesize_shortnames ? @@ -1228,11 +1203,7 @@ mps_routehdr_w(gbfile* mps_file, int mps_ver, const route_head* rte) } /* route name */ -#if NEW_STRINGS if (rte->rte_name.isEmpty()) { -#else - if (!rte->rte_name) { -#endif sprintf(hdr, "Route%04x", (unsigned) uniqueValue); rname = xstrdup(hdr); } else { @@ -1431,21 +1402,12 @@ mps_routedatapoint_w(gbfile* mps_file, int mps_ver, const waypoint* rtewpt) } QString src; -#if NEW_STRINGS if (!rtewpt->description.isEmpty()) { src = rtewpt->description; } if (!rtewpt->notes.isEmpty()) { src = rtewpt->notes; } -#else - if (rtewpt->description) { - src = rtewpt->description; - } - if (rtewpt->notes) { - src = rtewpt->notes; - } -#endif QString ident = global_opts.synthesize_shortnames ? mkshort(mkshort_handle, src) : CSTRc(rtewpt->shortname); @@ -1643,11 +1605,7 @@ mps_trackhdr_w(gbfile* mps_file, int mps_ver, const route_head* trk) } /* track name */ -#if NEW_STRINGS if (trk->rte_name.isEmpty()) { -#else - if (!trk->rte_name) { -#endif sprintf(hdr, "Track%04x", (unsigned) uniqueValue); tname = xstrdup(hdr); } else { diff --git a/gpsbabel/mmo.cc b/gpsbabel/mmo.cc index b6b9e6b9d..b886905ff 100644 --- a/gpsbabel/mmo.cc +++ b/gpsbabel/mmo.cc @@ -521,29 +521,17 @@ mmo_read_CObjWaypoint(mmo_data_t* data) } if (*cend++) { -#if NEW_STRINGS wpt->notes = QString::fromLatin1(cend); -#else - wpt->notes = xstrdup(cend); -#endif } if (wpt->HasUrlLink()) { DBG((sobj, "url = \"%s\"\n", wpt->url)); } } else if (*str) { -#if NEW_STRINGS wpt->notes = QString::fromLatin1(str); -#else - wpt->notes = xstrdup(str); -#endif } xfree(str); -#if NEW_STRINGS if (!wpt->notes.isEmpty()) { -#else - if (wpt->notes) { -#endif DBG((sobj, "notes = \"%s\"\n", wpt->notes)); } @@ -990,13 +978,13 @@ mmo_finalize_rtept_cb(const waypoint* wptref) wpt->latitude = wpt2->latitude; wpt->longitude = wpt2->longitude; - wpt->shortname = (wpt2->shortname); + wpt->shortname = wpt2->shortname; - wpt->description = (wpt2->description); + wpt->description = wpt2->description; wpt->notes = (wpt2->notes); if (wpt2->HasUrlLink()) { UrlLink l = wpt2->GetUrlLink(); - wpt->notes = xstrdup(l.url_.toUtf8().data()); + wpt->notes = l.url_; } wpt->proximity = wpt2->proximity; diff --git a/gpsbabel/naviguide.cc b/gpsbabel/naviguide.cc index c47e0a318..ca89cb8db 100644 --- a/gpsbabel/naviguide.cc +++ b/gpsbabel/naviguide.cc @@ -408,13 +408,8 @@ data_read(void) /* put the data in the waypoint structure */ ng_convert_datum(wpt_tmp); -#if NEW_STRINGS wpt_tmp->shortname = codec->toUnicode(WPNC.strName); wpt_tmp->description = codec->toUnicode(strComment); -#else - wpt_tmp->shortname = xstrdup(WPNC.strName); - wpt_tmp->description = xstrdup(strComment); -#endif if (process_rte) { route_add_wpt(rte_head, wpt_tmp); diff --git a/gpsbabel/navilink.cc b/gpsbabel/navilink.cc index 0d4d54a86..48b961d00 100644 --- a/gpsbabel/navilink.cc +++ b/gpsbabel/navilink.cc @@ -207,11 +207,7 @@ compare_waypoints(const waypoint* waypt1, const waypoint* waypt2) return waypt1->latitude == waypt2->latitude && waypt1->longitude == waypt2->longitude && waypt1->altitude == waypt2->altitude && -#if NEW_STRINGS waypt1->shortname == waypt2->shortname; -#else - strcmp(waypt1->shortname, waypt2->shortname) == 0; -#endif } unsigned diff --git a/gpsbabel/overlay.cc b/gpsbabel/overlay.cc index d285a0c5e..ae19f5b7e 100644 --- a/gpsbabel/overlay.cc +++ b/gpsbabel/overlay.cc @@ -222,11 +222,7 @@ static void route_add_name(const route_head* hd) route_head* route; route = (route_head*) hd; -#if NEW_STRINGS grp = route->rte_name.toInt(); -#else - grp = atoi(route->rte_name); -#endif i = 0; while (irte_name = name; -#else - route->rte_name = (char*) xrealloc(route->rte_name,(strlen(name)+1)*sizeof(char)); - strcpy(route->rte_name,name); -#endif } static void ovl_read(void) @@ -299,7 +290,7 @@ static void ovl_read(void) case 3: // Linie route_head = route_head_alloc(); route_head->rte_num = sym_cnt; - route_head->rte_name = xstrdup(pstr); /* use group-number for the moment */ + route_head->rte_name = pstr; /* use group-number for the moment */ route_add_head(route_head); break; } @@ -375,7 +366,7 @@ static void ovl_read(void) wpt->latitude = aktY; wpt->longitude = aktX; wpt->altitude = 0.0; - wpt->shortname = strdup(aktPath); + wpt->shortname = aktPath; waypt_add(wpt); break; #endif diff --git a/gpsbabel/ozi.cc b/gpsbabel/ozi.cc index c9a32c20c..7ee7136be 100644 --- a/gpsbabel/ozi.cc +++ b/gpsbabel/ozi.cc @@ -246,11 +246,7 @@ ozi_track_hdr(const route_head* rte) ozi_openfile(ozi_ofname); gbfprintf(file_out, ozi_trk_header, altunit == 'f' ? "Feet" : "Meters", -#if NEW_STRINGS rte->rte_name.isEmpty() ? "ComplimentsOfGPSBabel" : CSTRc(rte->rte_name)); -#else - rte->rte_name ? CSTRc(rte->rte_name) : "ComplimentsOfGPSBabel"); -#endif } track_out_count++; @@ -320,13 +316,8 @@ ozi_route_hdr(const route_head* rte) gbfprintf(file_out, "R,%d,%s,%s,\r\n", route_out_count, -#if NEW_STRINGS CSTRc(rte->rte_name), CSTRc(rte->rte_desc)); -#else - rte->rte_name ? CSTRc(rte->rte_name) : "", - rte->rte_desc ? CSTRc(rte->rte_desc) : ""); -#endif } static void @@ -370,19 +361,11 @@ ozi_route_disp(const waypoint* waypointp) gbfprintf(file_out, "W,%d,,%d,%s,%.6f,%.6f,%s,0,1,3,0,65535,%s,0,0\r\n", route_out_count, route_wpt_count, -#if NEW_STRINGS CSTR(waypointp->shortname), -#else - waypointp->shortname ? CSTRc(waypointp->shortname) : "", -#endif waypointp->latitude, waypointp->longitude, ozi_time, -#if NEW_STRINGS CSTR(waypointp->description)); -#else - waypointp->description ? CSTRc(waypointp->description) : ""); -#endif } @@ -787,7 +770,7 @@ data_read(void) while (s) { field ++; if (field == 4) { - trk_head->rte_name = xstrdup(lrtrim(s)); + trk_head->rte_name = QString(s).trimmed(); } s = csv_lineparse(NULL, ",", "", linecount); } @@ -886,13 +869,8 @@ ozi_waypt_pr(const waypoint* wpt) static int index = 0; double alt; char ozi_time[16]; -#if NEW_STRINGS QString description; QString shortname; -#else - char* description; - char* shortname; -#endif int faked_fsdata = 0; ozi_fsdata* fs = NULL; int icon = 0; @@ -911,13 +889,8 @@ ozi_waypt_pr(const waypoint* wpt) } else { alt = wpt->altitude * alt_scale; } -#if NEW_STRINGS if ((wpt->shortname.isEmpty()) || (global_opts.synthesize_shortnames)) { if (!wpt->description.isEmpty()) { -#else - if ((!wpt->shortname) || (global_opts.synthesize_shortnames)) { - if (wpt->description) { -#endif if (global_opts.synthesize_shortnames) { shortname = mkshort_from_wpt(mkshort_handle, wpt); } else { @@ -930,13 +903,8 @@ ozi_waypt_pr(const waypoint* wpt) } else { shortname = csv_stringclean(wpt->shortname, BADCHARS); } -#if NEW_STRINGS if (wpt->description.isEmpty()) { if (!shortname.isEmpty()) { -#else - if (!wpt->description) { - if (shortname) { -#endif description = csv_stringclean(shortname, BADCHARS); } else { description = xstrdup(""); @@ -963,11 +931,6 @@ ozi_waypt_pr(const waypoint* wpt) gbfprintf(file_out,"%d,", 0); } gbfprintf(file_out, "%.0f,%d,%d,%d\r\n", alt, 6, 0, 17); -#if NEW_STRINGS -#else - xfree(description); - xfree(shortname); -#endif if (faked_fsdata) { xfree(fs); diff --git a/gpsbabel/radius.cc b/gpsbabel/radius.cc index 10cc2b8c9..9bfa1b8b4 100644 --- a/gpsbabel/radius.cc +++ b/gpsbabel/radius.cc @@ -167,7 +167,7 @@ radius_process(void) if (routename) { rte_head = route_head_alloc(); - rte_head->rte_name = xstrdup(routename); + rte_head->rte_name = routename; route_add_head(rte_head); } diff --git a/gpsbabel/shape.cc b/gpsbabel/shape.cc index 8f7f6c6f4..91d20ddca 100644 --- a/gpsbabel/shape.cc +++ b/gpsbabel/shape.cc @@ -169,7 +169,7 @@ my_read(void) case SHPT_ARC: { int j; route_head* routehead = route_head_alloc(); - routehead->rte_name = xstrdup(name); + routehead->rte_name = name; route_add_head(routehead); for (j = 0; j < shp->nVertices; j++) { wpt = waypt_new(); diff --git a/gpsbabel/stmwpp.cc b/gpsbabel/stmwpp.cc index 0cbd2531a..96ebe2782 100644 --- a/gpsbabel/stmwpp.cc +++ b/gpsbabel/stmwpp.cc @@ -135,11 +135,7 @@ stmwpp_data_read(void) break; case 2: -#if NEW_STRINGS wpt->shortname = QString::fromLatin1(c); -#else - wpt->shortname = xstrdup(c); -#endif break; case 3: diff --git a/gpsbabel/transform.cc b/gpsbabel/transform.cc index 190f2eb1f..e8338141b 100644 --- a/gpsbabel/transform.cc +++ b/gpsbabel/transform.cc @@ -121,13 +121,9 @@ transform_rte_disp_hdr_cb(const route_head* rte) if (current_target == 'T') { current_trk = route_head_alloc(); track_add_head(current_trk); -#if NEW_STRINGS if (!rte->rte_name.isEmpty()) { -#else - if (rte->rte_name && *rte->rte_name) { -#endif xasprintf(¤t_trk->rte_desc, "Generated from route %s", CSTRc(rte->rte_name)); - current_trk->rte_name = xstrdup(rte->rte_name); /* name the new trk */ + current_trk->rte_name = rte->rte_name; /* name the new trk */ } } } @@ -146,18 +142,11 @@ transform_trk_disp_hdr_cb(const route_head* trk) if (current_target == 'R') { current_rte = route_head_alloc(); route_add_head(current_rte); -#if NEW_STRINGS if (!trk->rte_name.isEmpty()) { current_rte->rte_desc = "Generated from track "; current_rte->rte_desc += trk->rte_name; current_rte->rte_name = trk->rte_name; /* name the new rte */ } -#else - if (trk->rte_name && *trk->rte_name) { - xasprintf(¤t_rte->rte_desc, "Generated from track %s", CSTRc(trk->rte_name)); - current_rte->rte_name = xstrdup(trk->rte_name); /* name the new rte */ - } -#endif } } -- 2.30.2